<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>Document</title>
    <style>
        canvas{
            border: 1px solid black;
            display: block;
            margin: 0 auto;
        }
    </style>
</head>
<canvas id="myCanvas" width="500px" height="500px">
    您的浏览器不支持canvas，请更换浏览器
</canvas>
<script>
    var myCanvas = document.getElementById('myCanvas');
    var paint = myCanvas.getContext('2d');
     //首先，需要使用图片就得由img标签
    var img = new Image();
    //其次，引入图片路径
    img.src = 'img/picBg.jpg';
    //然后，等图片加载完成后再去设置图片显示
    img.onload = function(){
        //最后，图片显示
        paint.drawImage(img,200,200,100,100)
        //参数1：引入的图片标签  参数2,3：起始点的坐标x y 参数4,5：图片的宽和高
    }


</script>

<body>

</body>

</html>